package com.itheima.exception;

/**
 * @author Anomaly
 * @date 2023/2/6 18:25
 */
public class ExceptionDemo2 {
    public static void main(String[] args) {
        //数组索引越界异常 ArrayIndexOutOfBoundsException
        int[] arr = {0, 1, 2};
        System.out.println(arr[2]);
//        System.out.println(arr[3]);

        //空指针异常 NullPointerException
        String name = null;
        System.out.println(name);
//        System.out.println(name.length());

        //类型转换异常 ClassCastException
        Object o = 12;
//        String a = (String) o;

        //数学操作异常 ArithmeticException
//        int c = 1 / 0;

        //数字转换异常 NumberFormatException
        String number = "23a";
        Integer d = Integer.valueOf(number);

    }
}
